<%@page import="cn.jhc.dao.NewMsgDAO"%>
<%@page import="cn.jhc.bean.HfmsgBean"%>
<%@page import="cn.jhc.bean.UserBean"%>
<%@page import="cn.jhc.bean.AllHfmsgBean"%>
<%@page import="java.util.ArrayList"%>
<%@page import="cn.jhc.dao.ConnectionFactory"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" import="cn.jhc.bean.UserBean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="./css/taolunqu.css"></link>
<title>留言板</title>
</head>
<body>
	<%
		int CurrentPage = 1; //初始值,第一页
		int intPageCount; //全部的也数
		if (request.getParameter("page") != null) //判断传过来的数据
			CurrentPage = Integer.parseInt(request.getParameter("page")); //装换为整形
		if (CurrentPage < 1) //使初始值不小于一，始终是第一页
			CurrentPage = 1;
	%>
	<div id="wrapper">
		<%
			String id = request.getParameter("id");
			int Id = Integer.parseInt(id);
			HfmsgBean m = new HfmsgBean();
			NewMsgDAO dao = new NewMsgDAO();
			dao.setCon(ConnectionFactory.getConnection());
			m = dao.getoneMessages(Id);
			request.setAttribute("title", m);
		%>
		<%
			HfmsgBean t = new HfmsgBean();
			NewMsgDAO dao3 = new NewMsgDAO();
			dao3.setCon(ConnectionFactory.getConnection());
			t = dao3.getonetopMessages(Id);
			request.setAttribute("top", t);
		%>
		<%
			dao.setCon(ConnectionFactory.getConnection());
			ArrayList<AllHfmsgBean> h = new ArrayList<AllHfmsgBean>();
			h = dao.getHFMessages(Id, CurrentPage);
			request.setAttribute("liuyan", h);
		%>
		<%
			NewMsgDAO dao2 = new NewMsgDAO();
			dao2.setCon(ConnectionFactory.getConnection());
			intPageCount = dao2.getHfCount(Id);
			if (intPageCount == 0) {
				CurrentPage = 1;
				intPageCount = 1;
			} else {
				if (CurrentPage > intPageCount)
					CurrentPage = intPageCount;
			}
		%>
		<jsp:include page="./header.jsp"></jsp:include>
		<div id="wrapperdown">
		<table width="1000">
			<tr>
				<td width="400" height="200" rowspan="2" valign="top"><div
						align="left">昵称：${requestScope.title.displayname}${requestScope.top.displayname}</div></td>
				<td width="600" valign="top"><div align="left">标题：${requestScope.title.title}${requestScope.top.title}</div></td>
			</tr>
			<tr>
				<td valign="top"><div align="left">内容：${requestScope.title.content}${requestScope.top.content}</div></td>
			</tr>
			<c:forEach var="liuyan" items="${requestScope.liuyan}">
				<tr>
					<td height="200" valign="top"><div align="left">昵称：${liuyan.displayname}</div></td>
					<td valign="top"><div align="left">回复：${liuyan.content}</div></td>
				</tr>
			</c:forEach>
		</table>
		<div align="right">
			<a>第<%=CurrentPage%>页 共<%=intPageCount%>页
			</a> <a
				href="showNewsmessages.jsp?page=<%=1%>&id=${requestScope.title.id}">首页</a>
			<%
				if (CurrentPage > 1) {
			%>
			<a
				href="showNewsmessages.jsp?page=<%=CurrentPage-1%>&id=${requestScope.title.id}">上一页</a>
			<%
				} else {
			%>
			上一页
			<%
				}
			%>
			<%
				if (CurrentPage >= intPageCount) {
			%>
			下一页
			<%
				} else {
			%>
			<a
				href="showNewsmessages.jsp?page=<%=CurrentPage+1%>&id=${requestScope.title.id}">下一页</a>
			<%
				}
			%>
			<a
				href="showNewsmessages.jsp?page=<%=intPageCount%>&id=${requestScope.title.id}">末页</a>
		</div>
		<div id="submit">
			<form method="post"
				action="./addHfNewsmessage.do?titleid=${requestScope.title.id}&getb=/showNewsmessages.jsp&id=${requestScope.title.id}">
				<p>
					<label for="content">内容</label>
					<textarea rows="7" cols="60" name="content"></textarea>
				</p>
				<p>
					<input type="hidden" name="getb"
						value="/showNewsmessages.jsp?titleid=${requestScope.title.id}">
					<input type="submit" value="提交"></input> <input type="reset" />
				</p>
			</form>
		</div>
		</div>
		<jsp:include page="./copyright.jsp"></jsp:include>
	</div>
</body>
</html>